function successFunction()
{
	if($('input[name=action]').val()=="additem")//success on add
	{
		if(confirm("Do you want to add another?"))
		{
			location.href = "";
		}
		else
			location.href = root + module + "/manage.html";
	}
	else if($('input[name=action]').val()=="updateitem")//success on edit
	{
		if(confirm("Update successful. Go back to the list?"))
			location.href = root + module + "/manage.html";
		else
			location.href = "";
	}
	//hide validation
	$('.form').validationEngine('hide');
}

//listflex
$('.listFlex').flexigrid
(
	{
		autoload: true,
		height: $('#main').height(),
		title: 'Announcement List',
		url: root + module + '/listview',
		blockOpacity: 0,
		dataType: 'json',
		colModel : [
			{display: '', name : 'a.announcement_id', width : 40, align:'center', process: viewItem}
			,{display: 'Subject', name : 'a.subject', width : 104, align : 'left', sortable:true}
			,{display: 'Announcement', name : 'a.announcement', width : 100, align : 'left', sortable:true}
			,{display: 'Created Date', name : 'a.created', width : 100, align : 'left', sortable:true}
			,{display: 'Created By', name : 'created_by_name', width : 70, align : 'left', sortable:true}
			,{display: 'Modified Date', name : 'a.modified', width : 100, align : 'left', sortable:true}
			,{display: 'Modified By', name : 'modified_by_name', width : 70, align : 'left', sortable:true}
			// ,{display: 'Username', name : 'a.username', width : 100, align : 'left', sortable:true}
			// ,{display: 'Email', name : 'a.email', width : 150, align : 'left', sortable:true}
			// ,{display: 'Role', name : 'b.role_name', width : 80, align : 'left', sortable:true}
			],
		buttons : [
			{name: 'Add', bclass: 'add', onpress : addItem},
			//{separator: true},
			{name: 'Delete', bclass: 'delete', onpress : deleteItem},
			//{separator: true}
		],
		newp: 1,
		sortname: "a.announcement_id",
		sortorder: "desc",
		rp: 40,
		usepager: true,
		useRp: true,
		resizable: true,
		showTableToggleBtn: true,
		singleSelect: false
	}
);
